package ruifeng.zcj.communcationring.base.base_web_activity.other;

import android.util.Log;
import android.webkit.JavascriptInterface;

import ruifeng.zcj.communcationring.base.base_web_activity.WebViewActivity;

/**
 * http://itfish.net/article/25514.html
 * Created by Administrator on 2016/8/26 0026.
 */
public class JS {
    WebViewActivity.TextViewChanger mTextViewChanger;
    public String jsona;// 传递json串给html的js代码


    public void setTextChanger(WebViewActivity.TextViewChanger textChanger) {
        this.mTextViewChanger = textChanger;
    }

    /**
     * 如果 targetSdkVersion >=17，一定要加注解，否则JS无法调用这个方法
     */
    @JavascriptInterface
    public void jsCallJava(String arg) {
        if (mTextViewChanger != null) {
            mTextViewChanger.changeText(arg);
        }
    }

    /**
     * 如果 targetSdkVersion >=17，一定要加注解，否则JS无法调用这个方法
     */
    @JavascriptInterface
    public void jsCallJava2(String arg) {
        if (mTextViewChanger != null) {
            mTextViewChanger.changeText(arg);
        }
    }

    private JSListener listener;

    public void setShareListener(JSListener listener) {
        this.listener = listener;
    }

    @JavascriptInterface
    public void uploadfileimg(String arg) {
        listener.uploadfileimg(arg);
    }

    public interface JSListener {
        void uploadfileimg(String param);
    }
}
